package com.booking.controller;

import com.booking.common.dto.ClientResp;
import com.booking.common.dto.PageReq;
import com.booking.common.dto.PageResp;
import com.booking.dao.entity.AuditRecord;
import com.booking.service.AuditService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author Qikai.Lin
 * @date 2023/4/23
 */
@Slf4j
@RestController
@RequestMapping("/api/audit")
public class AuditController {

    @Autowired
    private AuditService auditService;
    //查看待审核信息
    @PostMapping("/getAll")
    public ClientResp<PageResp<AuditRecord>> getAll(@RequestBody @Valid PageReq<Object> request) {
        return ClientResp.success(auditService.getAll(request));
    }
    //终止订单
    @PostMapping("/shutdown")
    public ClientResp<String> shutdown(@RequestParam Long recordId) {
        auditService.shutdown(recordId);
        return ClientResp.success();
    }
    //拒绝订单
    @PostMapping("/reject")
    public ClientResp<String> reject(@RequestParam Long recordId) {
        auditService.reject(recordId);
        return ClientResp.success();
    }
}
